const dgram = require('dgram');
const message = Buffer.from([
    0x58, 0x02, 0x00, 0x01, 0x00, 0x00, 0x16, 0x4a, 0x27, 0x2a, 0xe2, 0x39, 0xb2, 0x76, 0x32, 0x06, 0x74, 0x68, 0x69, 0x6e, 0x67, 0x73, 
    0x0d, 0x1e, 0x49, 0x56, 0x52, 0x69, 0x42, 0x43, 0x63, 0x52, 0x36, 0x48, 0x50, 0x70, 0x5f, 0x43, 0x63, 0x5a, 0x49, 0x46, 0x66, 0x4f, 
    0x5a, 0x46, 0x78, 0x7a, 0x5f, 0x69, 0x7a, 0x6e, 0x69, 0x35, 0x78, 0x63, 0x5f, 0x4b, 0x4f, 0x2d, 0x6b, 0x67, 0x53, 0x41, 0x32, 0x59, 
    0x38, 0x11, 0x3c, 0x51, 0x3c, 0xff, 0xbf, 0x66, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x73, 0x9f, 0xbf, 0x63, 0x6b, 0x65, 0x79, 0x63, 0x74, 
    0x6d, 0x70, 0x65, 0x76, 0x61, 0x6c, 0x75, 0x65, 0xfb, 0x40, 0x3c, 0x33, 0x33, 0x33, 0x33, 0x33, 0x33, 0xff, 0xff, 0xff
]);
const client = dgram.createSocket('udp4');
client.send(message, 5683, 'coap.thethings.io', (err) => {
    if (err) { console.log(err); }
    client.close();
    setTimeout(() => { console.log('Done'); }, 5000);
});

/*
s.split(' ').map(x => "0x" + x).join(', ')
*/